﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;

using PRET.ReportDataDefine.UIData;
using PRET.DBAdapter;

namespace PRET.PRETWebService
{
    // 注意: 使用“重构”菜单上的“重命名”命令，可以同时更改代码、svc 和配置文件中的类名“PRETService”。
    // 注意: 为了启动 WCF 测试客户端以测试此服务，请在解决方案资源管理器中选择 PRETService.svc 或 PRETService.svc.cs，然后开始调试。
    public class PRETWebService : IPRETWebService
    {
        private static ServiceAdapter adapter = null;

        public PRETWebService()
        {
            if (adapter == null)
                adapter = new ServiceAdapter();
        }

        public List<OrderCheckInfo> GetJCJOrderList()
        {
            //List<DBadapter.Data.OrderCheckInfo> list = adapter.GetJCJOrderList();
            //List<OrderCheckInfo> retList = new List<OrderCheckInfo>();
            //foreach (DBadapter.Data.OrderCheckInfo item in list)
            //    retList.Add(ConvertData.Convert(item));
            //return retList;
            return adapter.GetJCJOrderList();
        }

        public List<OrderCheckInfo> GetJHJOrderList()
        {
            return adapter.GetJHJOrderList();
            //List<DBadapter.Data.OrderCheckInfo> list = adapter.GetJHJOrderList();
            //List<OrderCheckInfo> retList = new List<OrderCheckInfo>();
            //foreach (DBadapter.Data.OrderCheckInfo item in list)
            //    retList.Add(ConvertData.Convert(item));
            //return retList;
        }

        public List<ProductionReport> GetProductionReport(OrderCheckInfo bn)
        {
            return adapter.GetProductionReport(bn);
            //DBadapter.Data.OrderCheckInfo order = ConvertData.Convert(bn);
            //DBadapter.Data.ProductionReport obj = adapter.GetProductionReport(order);
            //return ConvertData.Convert(obj);
        }

        public List<JHJReport> GetJHJReport(OrderCheckInfo bn)
        {
            return adapter.GetJHJReport(bn);
            //DBadapter.Data.OrderCheckInfo order = ConvertData.Convert(bn);
            //DBadapter.Data.JHJReport obj = adapter.GetJHJReport(order);
            //return ConvertData.Convert(obj);
        }

        public List<DeviceRunReport> GetDeviceRunReport()
        {
            return adapter.GetDeviceRunReport();
            //List<DBadapter.Data.DeviceRunReport> list = adapter.GetDeviceRunReport();
            //List<DeviceRunReport> retList = new List<DeviceRunReport>();
            //foreach (DBadapter.Data.DeviceRunReport item in list)
            //    retList.Add(ConvertData.Convert(item));
            //return retList;
        }

        public List<float> GetMeterUnitPrice()
        {
            return adapter.GetMeterUnitPrice();
        }

        public MeterReadingReport GetMeterReadingReport(DateTime startTime, DateTime endTime, float peakPrice, float genPrice, float lowPrice)
        {
            return adapter.GetMeterReadingReport(startTime, endTime, peakPrice, genPrice, lowPrice); 
            //DBadapter.Data.MeterReadingReport obj = adapter.GetMeterReadingReport(startTime, endTime);
            //return ConvertData.Convert(obj);
        }

        public List<string> GetHighLowDeviceList()
        {
            return adapter.GetHighLowDeviceList(); 
        }

        public List<HighLowStatusReport> GetHighLowStatusReport(string deviceID, DateTime month)
        {
            return adapter.GetHighLowStatusReport(deviceID, month); 
            //List<DBadapter.Data.HighLowStatusReport> list = adapter.GetHighLowStatusReport();
            //List<HighLowStatusReport> retList = new List<HighLowStatusReport>();
            //foreach (DBadapter.Data.HighLowStatusReport item in list)
            //    retList.Add(ConvertData.Convert(item));
            //return retList;
        }

        public HighLowVoltageReport GetHighLowVoltageReport(DateTime startTime, DateTime endTime)
        {
            return adapter.GetHighLowVoltageReport(startTime, endTime);
        }

        public List<ProductiveTaskReportTV> GetProductiveTaskReport()
        {
            //return adapter.GetProductiveTaskReport();
            return adapter.GetProductiveTaskReportForTV();
            //List<DBadapter.Data.ProductiveTaskReport> list = adapter.GetProductiveTaskReport();
            //List<ProductiveTaskReport> retList = new List<ProductiveTaskReport>();
            //foreach (DBadapter.Data.ProductiveTaskReport item in list)
            //    retList.Add(ConvertData.Convert(item));
            //return retList;
        }

        public List<ProductionLineEfficiencyReport> GetProductionLineEfficiencyReport(DateTime year, Dictionary<string, int> quota)
        {
            return adapter.GetProductionLineEfficiencyReport(year, quota);
            //List<DBadapter.Data.ProductionLineEfficiencyReport> list = adapter.GetProductionLineEfficiencyReport(year);
            //List<ProductionLineEfficiencyReport> retList = new List<ProductionLineEfficiencyReport>();
            //foreach (DBadapter.Data.ProductionLineEfficiencyReport item in list)
            //    retList.Add(ConvertData.Convert(item));
            //return retList;
        }

        public List<TeamEfficiencyReport> GetTeamEfficiencyReport(DateTime year, Dictionary<string, int> quota)
        {
            return adapter.GetTeamEfficiencyReport2(year, quota);
            //List<DBadapter.Data.TeamEfficiencyReport> list = adapter.GetTeamEfficiencyReport(year);
            //List<TeamEfficiencyReport> retList = new List<TeamEfficiencyReport>();
            //foreach (DBadapter.Data.TeamEfficiencyReport item in list)
            //    retList.Add(ConvertData.Convert(item));
            //return retList;
        }

        public void CorrectJCJOrderTime(OrderCheckInfo order)
        {
            adapter.CorrectJCJOrderTime(order);
            //DBadapter.Data.OrderCheckInfo obj = ConvertData.Convert(order);
            //adapter.CorrectJCJOrderTime(obj);
        }

        public void CorrectJHJOrderTime(OrderCheckInfo order)
        {
            adapter.CorrectJHJOrderTime(order);
            //DBadapter.Data.OrderCheckInfo obj = ConvertData.Convert(order);
            //adapter.CorrectJHJOrderTime(obj);
        }

        public void IgnoreERPOrderTime(OrderCheckInfo order)
        {
            adapter.IgnoreERPOrderTime(order);
        }

        public List<Dictionary<string, List<EmployeAttendance>>> GetAllDepEmployeAttendance(DateTime month)
        {
            return adapter.GetAllDepEmployeAttendance(month);
        }

        public TeamAttendanceMain GetAllTeamAttendance(DateTime month)
        {
            return adapter.GetAllTeamAttendance(month);
        }

        public void SetTeamAttendanceHours(double AHours, double BHours, double CHours, double DHours, double EHours, double FHours, DateTime month)
        {
            adapter.SetTeamAttendanceHours(AHours, BHours, CHours, DHours, EHours, FHours, month);
        }

        public List<TeamAttendanceRestHours> GetTeamAttendanceHoursList(DateTime month)
        {
            return adapter.GetTeamAttendanceHoursList(month);
        }

        public List<HSMLJData> GetHSMLJReport(DateTime date)
        {
            return adapter.GetHSMLJReport(date);
        }

        public List<ProductionReportSummaryForJSON> GetProLineStatus()
        {
            return adapter.GetProLineStatus();
        }

        public Dictionary<string, int> GetEfficiencyQuota(int type)
        {
            return adapter.GetEfficiencyQuota(type);
        }

        public List<ProductionLineStandby> GetProductionLineStandby(DateTime year)
        {
            return adapter.GetProductionLineStandby(year);
        }

        public TVControlInfo GetTVControlInfo()
        {
            return adapter.GetTVControlInfo();
        }

        public void SaveTVControlInfo(TVControlInfo info)
        {
            adapter.SaveTVControlInfo(info);
        }

        //public void testProLineStatus()
        //{
        //    adapter.GetProLineStatus();
        //}
    }
}
